from api.loginApi import IhrmLogin
from common.assertTools import common_assert
import pytest
import logging

from common.read_json import read_json
from config import BASE_PATH


class TestIhrmLogin(object):
    def setup_class(self):
        # 创建实例
        self.ihrm_login = IhrmLogin()

    # 拼接json文件的绝对路径,读取,获得[(),()]格式数据
    filename = BASE_PATH + "/data/login.json"
    res = read_json(filename)
    @pytest.mark.parametrize("desc,req_body,status_code,success,code,message",res)
    def test_login(self,desc,req_body,status_code,success,code,message):
        resp = self.ihrm_login.login(req_body)
        # print(desc,":",resp.json())
        logging.info(f"{desc}:{resp.json()}")
        common_assert(resp,status_code,success,code,message)

